#[cfg(test)]
mod tests {
    use log::{error, info};
    use my_util_lib::{cron_, log_util};
    use tokio::runtime::Runtime;

    #[test]
    pub fn test_demo() {
        cron_::demo();
    }

    pub fn create_runtime() -> Runtime {
        // 创建单一线程的runtime
        let rt = tokio::runtime::Builder::new_current_thread()
            //.enable_io() // 可在runtime中使用异步IO
            .enable_time() // 可在runtime中使用异步计时器(timer)
            .build()
            .unwrap();
        rt
    }

    #[test]
    pub fn test_next_execute_point() {
        let _ = log_util::init_log("log4rs.yaml");
        let rt = create_runtime();
        rt.block_on(async {
            let r = cron_::next_execute_point("0 04 18 * * ?").await;
            match r {
                Ok(()) => {
                    info!("完成")
                }
                Err(e) => {
                    error!("错误:{}", e);
                }
            }
        });
    }

    #[test]
    pub fn test_next_execute_point2() {
        let _ = log_util::init_log("log4rs.yaml");
        // 创建单一线程的runtime
        let rt = create_runtime();
        rt.block_on(async {
            // 循环
            loop {
                //每5秒执行一次
                let r = cron_::next_execute_point("0/5 * * * * *").await;
                match r {
                    Ok(()) => {
                        info!("完成")
                    }
                    Err(e) => {
                        error!("错误:{}", e);
                    }
                }
            }
        });
    }
    #[test]
    pub fn test_loop_execute_point2() {
        let _ = log_util::init_log("log4rs.yaml");
        // 创建单一线程的runtime
        let rt = create_runtime();
        rt.block_on(async {
            let r = cron_::loop_execute_point("0/5 * * * * *").await;
            r.unwrap();
        });
    }
}
